package com.changgou.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.swagger.readers.operation.SwaggerOperationResponseClassReader;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 李民康
 * @date 2022/1/13 10:03
 */
//@Component
//@Primary
public class SwaggerConfig implements SwaggerResourcesProvider {

    @Override
    public List<SwaggerResource> get() {

        List resources = new ArrayList<>();

        /**
         * goods --->  这个就是个模块的名字，可以随便起
         * /goods/v2/api-docs ---> member就是application.yml配置的路由路径，后面的/v2/api-docs固定写法
         */
        resources.add(swaggerResource("goods模块", "/goods/v2/api-docs", "2.0"));
        resources.add(swaggerResource("file文件模块", "/file/v2/api-docs", "2.0"));

        return resources;
    }

    private Object swaggerResource(String name, String location, String version) {

        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}